import com.spring.demo.Student;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.ClassPathResource;

public class App2 {
    public static void main(String[] args) {
        // 1. 得到Spring上下文对象
        BeanFactory beanFactory = new XmlBeanFactory(new ClassPathResource("spring-config.xml"));

        // 2. 从spring容器中获取bean对象
        Student student = (Student)beanFactory.getBean("student"); // 根据名称获取
        //Student student = beanFactory.getBean(Student.class); // 根据类型获取

        //3. 使用bean
        student.play();
    }
}
